package com.yunxi.service.dubboService.impl.sto;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.pmsToMQ.pojo.VehiclePdiBillCheckMQVO;
import com.yunxi.pmsToMQ.service.StoPdiCheckToMQService;
import com.yunxi.sto.pojo.VehiclePdiBillCheckVO;
import com.yunxi.sto.service.VehiclePdiBillDubboService;
import org.apache.commons.beanutils.BeanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * <p>
 * oms接收MQ消息处理PDI检查 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-09-24
 */

public class StoPdiCheckToMQServiceImpl implements StoPdiCheckToMQService {

    private static final Logger logger = LoggerFactory.getLogger(SapVehicleDeliveryServiceImpl.class);

    @Autowired
    @Qualifier(value = "vehiclePdiBillDubboServiceImpl")
    VehiclePdiBillDubboService vehiclePdiBillDubboService;

    /**
     * 保存PDI检查
     * @param vehiclePdiBillCheckMQVO
     * @return
     * @throws Exception
     */
    @Override
    public ApiResult savePdiCheckFromMq(VehiclePdiBillCheckMQVO vehiclePdiBillCheckMQVO) throws Exception {
        logger.info("=====================接收PDI检查MQ消息成功====================");
        try {
            VehiclePdiBillCheckVO vehiclePdiBillCheckVO = new VehiclePdiBillCheckVO();
            BeanUtils.copyProperties(vehiclePdiBillCheckVO,vehiclePdiBillCheckMQVO);
            vehiclePdiBillDubboService.check(vehiclePdiBillCheckVO);
            logger.info("=====================接收PDI检查MQ消息完成====================");
            return ResponseUtil.ok("PDI检查成功");
        }
        catch (Exception e){
            return ResponseUtil.ok("PDI检查失败");
        }
    }
}
